<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>递归学习</title>
  </head>
  <body>
    <script>
      //4*3*2*1
      function test(n) {
        if (n === 1) {
          return 1;
        } else {
          return test(n - 1) * n;
        }
      }
      console.log("阶乘!", test(4));
      //计算 7!−4! 的结果。
      function test(a,b){
        if(a===0 || b===0){
          return;
        }
        return a*test(a-1,b) - b*test
      }
    </script>
  </body>
</html>
